/*
 * =====================================================================================
 *
 *       Filename:  net_ut.cxx
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  10/12/2010 07:25:33 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Chen Ken (Ken), zlchen.ken@gmail.com
 *        Company:  EMC
 *
 * =====================================================================================
 */

#define BOOST_TEST_MODULE net_ut 
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>

#include <string>
#include <iostream>
#include "cl_socket_addr.hxx"
#include "cl_socket_addr_in4.hxx"
#include "cl_socket.hxx"
#include "cl_server_socket.hxx"
#include "cl_client_socket.hxx"


using namespace std;
using namespace neo;

BOOST_AUTO_TEST_SUITE(net_ut)

BOOST_AUTO_TEST_CASE(socket_test)
{
#ifndef CL_SERVER
	CLServerSocket sock("localhost", 8080, CL_SOCK_STREAM);
  CLSocketAddr* clientAddr;
	BOOST_CHECK(sock.isValid() == true);
  BOOST_CHECK(sock.bind() == true);
  BOOST_CHECK(sock.listen() == true);
  BOOST_CHECK(sock.accept(clientAddr) == true);

#else
	CLClientSocket sock("localhost", 8080, CL_SOCK_STREAM);
	BOOST_CHECK(sock.isValid() == true);
	BOOST_CHECK(sock.connect() == true);
#endif
}

BOOST_AUTO_TEST_SUITE_END()

